package com.lzy.system.organization.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzy.system.organization.entity.SysRes;
import com.lzy.system.organization.entity.SysResRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 角色资源
 * </p>
 *
 * @author lcc
 * @since 2022-08-17
 */
@Repository
public interface SysResRoleMapper extends BaseMapper<SysResRole> {
    @Select("select id,link,resName,createDate from sys_res where id in (select resId from sys_res_role where ROLEID in (select RID from sys_user_role where uid in (select id from sys_user where username=#{uid}) ))")
    List<SysRes> queryByUid(@Param("uid") String uid);
    @Select("select id,link,resName,createDate from sys_res where INSTR (link, #{url})=1 and id in (select resId from sys_res_role where ROLEID in (select RID from sys_user_role where uid in (select id from sys_user where username=#{uid}) ))")
    List<SysRes> queryByUidAndUrl(@Param("uid") String uid,@Param("url") String url);
}
